package com.peiqi.oneisall.handler;

import cn.hutool.http.HttpStatus;
import com.peiqi.oneisall.domain.vo.ResponseVO;
import com.peiqi.oneisall.exception.BusinessException;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(BusinessException.class)
    public ResponseVO<Void> handlerServiceException(BusinessException e, HttpServletRequest request){
        log.error(e.getMessages(),e);
        return ResponseVO.error(HttpStatus.HTTP_CONFLICT,e.getMessages());
    }
}
